home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / amos / AMOSList0993.lzh / AMOSLIST / 000323_amos-request@svcs1.digex.net_Sun Oct 3 03:20:39 1993.msg < prev    next >
Internet Message Format  |  1993-10-03  |  7KB

  1. Received: from nextsun.INS.CWRU.Edu by access.digex.net with SMTP id AA22434
  2.   (5.67a8/IDA-1.4.4 for <mcox@access.digex.com>); Sun, 3 Oct 1993 03:20:34 -0400
  3. Received: from svcs1.digex.net by nextsun.INS.CWRU.Edu with SMTP (5.65b+ida+/CWRU-1.5.2-freenet-gw)
  4.     id AA16925; Sun, 3 Oct 93 03:20:20 -0400 (from amos-request@svcs1.digex.net for mcox@access.digex.com)
  5. Received: by svcs1.digex.net id AA00493
  6.   (5.65c/IDA-1.4.4 for amos-list-out); Sun, 3 Oct 1993 03:04:42 -0400
  7. Received: from access.digex.net by svcs1.digex.net with SMTP id AA00489
  8.   (5.65c/IDA-1.4.4 for <amos-list@svcs1.digex.net>); Sun, 3 Oct 1993 03:04:39 -0400
  9. Received: from sol.ccs.deakin.edu.au by access.digex.net with SMTP id AA12035
  10.   (5.67a8/IDA-1.4.4 for <amos-list@access.digex.net>); Sun, 3 Oct 1993 03:03:58 -0400
  11. Received: from mensa.ccs.deakin.edu.au (mensa.ccs.deakin.edu.au [128.184.102.1]) by sol.ccs.deakin.edu.au (8.5/1.3) with SMTP id RAA12507; Sun, 3 Oct 1993 17:03:18 +1000
  12. Received: by mensa.ccs.deakin.edu.au (4.1/client-1.3)
  13.     id AA23750; Sun, 3 Oct 93 17:03:17 EST
  14. Date: Sun, 3 Oct 1993 16:55:14 +1000 (EST)
  15. From: Scott Southurst <maverick@deakin.edu.au>
  16. Subject: The 3d proggy. (4k [ish])
  17. To: LIST AMOS <amos-list@access.digex.net>
  18. Message-Id: <Pine.3.07.9310031614.A23059-d100000@mensa.ccs.deakin.edu.au>
  19. Mime-Version: 1.0
  20. Content-Type: TEXT/PLAIN; charset=US-ASCII
  21. Status: RO
  22.  
  23. Coz people keep asking me for the 3d proggy I previously mentioned I have
  24. decided to send it to the list.  NOTE: It is only a simple routine.  It
  25. rotates the defined object around 2 axis.  The Y-axis (Moveable axis) and
  26. the x axis (fixed).  The program has been written to give people an idea
  27. of how 3d gfx is done and how hidden vertices is done.  When I improve the
  28. rotations etc. I'll notify all.
  29.  
  30. WANTED:  A "Blank extension" source code.  I have the "remains" of source
  31. codes but they don't seem to work when I remove the code so that they
  32. compile (ie. I remove all the functions etc. so that the file may be used
  33. as a template).  The files then compile but AMOS won't boot (AMOS
  34. Creator v1.34)
  35.  
  36. NOTE 2: There is a slight error in the definition of the object.  I think
  37. it may be due to the equations I used (Not mine,  I got them from a book).
  38.  I'll have to dig out my equations to see where the error lies.  The
  39. object will still work OK but the direction it may face will not be as
  40. expected.
  41.  
  42. 8<-------------------------cut here----------------------------------------
  43. '                                                             
  44. '                   Maverick 1993.                               
  45. '                                                             
  46. '                     27-9-1993                                 
  47. '
  48. '   NOTE:  The documentation has been provided for those who need to 
  49. '          learn from this program.  One interesting thing which can 
  50. '          be learnt is that comments take time when the program  is 
  51. '          run in the interpreter.  What this means is for the prog- 
  52. '          ram to be viewed at  its best remove the comments  before 
  53. '          running (OR compile it).
  54. '
  55. Set Buffer 20
  56. Degree 
  57. Screen Open 0,320,256,16,0
  58. Flash Off 
  59. Curs Off 
  60. Hide 
  61. Cls 0
  62. Double Buffer 
  63. Autoback 0
  64. '
  65. Close Editor 
  66. Close Workbench 
  67. '
  68. Dim OBJ(200,12),SYN(360),COZ(360)
  69. Global OBJ(),SYN(),COZ(),S
  70. SETUP
  71. PITCH=0
  72. YAW=0
  73. DELTADEG=15
  74. '
  75. '   Main Loop
  76. '
  77. Repeat 
  78.    Add PITCH,DELTADEG*(Jup(1)-Jdown(1)),DELTADEG To 360
  79.    Add YAW,DELTADEG*(Jleft(1)-Jright(1)),DELTADEG To 360
  80.    ROTATE[YAW,PITCH]
  81.    Screen Swap 
  82.    Wait Vbl 
  83.    Cls 0
  84. Until Mouse Key<>0 or Fire(1)
  85. '
  86. '   End of program 
  87. '
  88. Procedure SETUP
  89. '
  90. '    This procedure is used to setup the arrays.  SYN contains the sine
  91. '    values for deg=0 to 360.  COZ is the same for the cosine values.
  92. '    OBJ contains the points for the object:-
  93. '      OBJ(n,1) = x1   OBJ(n,2) = y1   OBJ(n,3) = z1 ... 
  94. '      OBJ(n,9) = z3 
  95. '
  96.    For COUNT=0 To 360
  97.       SYN(COUNT)=10000*Sin(COUNT)
  98.       COZ(COUNT)=10000*Cos(COUNT)
  99.    Next COUNT
  100.    Restore DATER
  101.    Repeat 
  102.       Inc PNTS
  103.       For COUNT=0 To 9
  104.          Read OBJ(PNTS,COUNT)
  105.       Next COUNT
  106.       Read WORD$
  107.    Until WORD$="ENDDATA"
  108. '
  109. '   The following stores the number of faces in the object.
  110. '
  111.    OBJ(0,0)=PNTS
  112. '
  113. '   The following contains the data for all the points in the object.
  114. '   Three points per polygon.  "CONT" is meaningless.  "ENDDATA" marks 
  115. '   the end of the data for the object.
  116. '   The first field in the object is the colour of the polygon.
  117. '   For the hidden face calculations to be consistant the points MUST
  118. '   be defined in an anticlockwise direction when looking at the face
  119. '   "HEAD-ON" (ie. from out of the object in)
  120. '
  121. DATER:
  122.    Data 6,30,15,30,30,15,-30,0,-15,0,"CONT"
  123.    Data 4,-30,15,30,30,15,30,0,-15,0,"CONT"
  124.    Data 6,-30,15,-30,-30,15,30,0,-15,0,"CONT"
  125.    Data 4,30,15,-30,-30,15,-30,0,-15,0,"CONT"
  126.    Data 15,30,15,30,-30,15,-30,30,15,-30,"CONT"
  127.    Data 13,-30,15,-30,30,15,30,-30,15,30,"ENDDATA"
  128. End Proc
  129. Procedure ROTATE[YAW,PITCH]
  130.    '
  131.    '   Put simply this procedure draws the object.
  132.    '
  133.    For COUNT=1 To OBJ(0,0)
  134.       '
  135.       '   First the object is rotated about the Y axis (YAWED).
  136.       '
  137.       X1=((OBJ(COUNT,3)*COZ(YAW))/10000)-((OBJ(COUNT,1)*SYN(YAW))/10000)
  138.       X2=((OBJ(COUNT,6)*COZ(YAW))/10000)-((OBJ(COUNT,4)*SYN(YAW))/10000)
  139.       X3=((OBJ(COUNT,9)*COZ(YAW))/10000)-((OBJ(COUNT,7)*SYN(YAW))/10000)
  140.       Z1=((OBJ(COUNT,3)*SYN(YAW))/10000)+((OBJ(COUNT,1)*COZ(YAW))/10000)
  141.       Z2=((OBJ(COUNT,6)*SYN(YAW))/10000)+((OBJ(COUNT,4)*COZ(YAW))/10000)
  142.       Z3=((OBJ(COUNT,9)*SYN(YAW))/10000)+((OBJ(COUNT,7)*COZ(YAW))/10000)
  143.       '
  144.       '   Next the object is rotated about the X axis (PITCHED). 
  145.       '
  146.       Y1=((OBJ(COUNT,2)*COZ(PITCH))/10000)-((Z1*SYN(PITCH))/10000)
  147.       Y2=((OBJ(COUNT,5)*COZ(PITCH))/10000)-((Z2*SYN(PITCH))/10000)
  148.       Y3=((OBJ(COUNT,8)*COZ(PITCH))/10000)-((Z3*SYN(PITCH))/10000)
  149.       Z1=((OBJ(COUNT,2)*SYN(PITCH))/10000)+((Z1*COZ(PITCH))/10000)
  150.       Z2=((OBJ(COUNT,5)*SYN(PITCH))/10000)+((Z2*COZ(PITCH))/10000)
  151.       Z3=((OBJ(COUNT,8)*SYN(PITCH))/10000)+((Z3*COZ(PITCH))/10000)
  152.       '
  153.       '   The normal vector for the face is calculated.
  154.       '
  155.       A=(Y1*(Z2-Z3))+(Y2*(Z3-Z1))+(Y3*(Z1-Z2))
  156.       B=(X1*(Z3-Z2))+(X2*(Z1-Z3))+(X3*(Z2-Z1))
  157.       C=(X1*(Y2-Y3))+(X2*(Y3-Y1))+(X3*(Y1-Y2))
  158.       Ink OBJ(COUNT,0)
  159.       '
  160.       '   If the face is pointing into the screen then don't draw. 
  161.       '
  162.       If C=>0
  163.          Polygon X1+160,Y1+128 To X2+160,Y2+128 To X3+160,Y3+128
  164.       End If 
  165.    Next COUNT
  166. End Proc
  167. 8<-------------------------cut here----------------------------------------
  168.  
  169.